<html>
<head><meta charset="utf-8"><title>Examples of bad Rust SIMD perf? · project-portable-simd · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/index.html">project-portable-simd</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Examples.20of.20bad.20Rust.20SIMD.20perf.3F.html">Examples of bad Rust SIMD perf?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="242118766"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Examples%20of%20bad%20Rust%20SIMD%20perf%3F/near/242118766" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Examples.20of.20bad.20Rust.20SIMD.20perf.3F.html#242118766">(Jun 09 2021 at 19:40)</a>:</h4>
<p>So one thing we could use to help motivate a solution to <a href="https://github.com/rust-lang/rust/issues/64609">https://github.com/rust-lang/rust/issues/64609</a> is if we could find examples of bad or divergent SIMD performance for Rust on a given architecture vs C (clang) on a given architecture. I had a conversation or two with people who have somewhat more familiarity with the compiler-level SIMD stuff (but not necessarily more familiarity with SIMD overall) and they expect LLVM to see through and properly handle the "pass through memory" trick if things are inlined.</p>
<p>This obviously is not at all the case where we just completely scalarize things, so we're ignoring <a href="https://github.com/rust-lang/stdsimd/issues/76">stdsimd#76</a> for the purposes of this example.<br>
If we can cough up examples we can compare against, it would help us bench, profile, and test possible solutions.<br>
I'm also not actually limiting this to <strong>just</strong> C, clang just happens to be there and is also LLVM driven. Anything where our SIMD takes a beating vs. ${LANG} is a good example.</p>



<a name="242118987"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Examples%20of%20bad%20Rust%20SIMD%20perf%3F/near/242118987" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Examples.20of.20bad.20Rust.20SIMD.20perf.3F.html#242118987">(Jun 09 2021 at 19:42)</a>:</h4>
<p>So not necessarily related to stdsimd but I've written relatively complex simd with stdarch and it definitely inlines fine</p>



<a name="242119109"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Examples%20of%20bad%20Rust%20SIMD%20perf%3F/near/242119109" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Examples.20of.20bad.20Rust.20SIMD.20perf.3F.html#242119109">(Jun 09 2021 at 19:44)</a>:</h4>
<p>Yeah, it's fine if it's not related to us directly, since I'm thinking about concerns re: compiler-level issues.</p>



<a name="242119584"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Examples%20of%20bad%20Rust%20SIMD%20perf%3F/near/242119584" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Examples.20of.20bad.20Rust.20SIMD.20perf.3F.html#242119584">(Jun 09 2021 at 19:47)</a>:</h4>
<p>Once we get to nightly I'll port my fourier crate to get a sense of actual performance in an actual application</p>



<a name="242119675"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Examples%20of%20bad%20Rust%20SIMD%20perf%3F/near/242119675" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Examples.20of.20bad.20Rust.20SIMD.20perf.3F.html#242119675">(Jun 09 2021 at 19:48)</a>:</h4>
<p>Not exactly a comparison vs C but it's something that's easy to benchmark</p>



<a name="242122746"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Examples%20of%20bad%20Rust%20SIMD%20perf%3F/near/242122746" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Examples.20of.20bad.20Rust.20SIMD.20perf.3F.html#242122746">(Jun 09 2021 at 20:09)</a>:</h4>
<p>opened an issue because tickets are possibly more useful here, especially if we can catch drive by reports. ^^;; <a href="https://github.com/rust-lang/stdsimd/issues/135">https://github.com/rust-lang/stdsimd/issues/135</a></p>



<a name="242148703"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Examples%20of%20bad%20Rust%20SIMD%20perf%3F/near/242148703" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Examples.20of.20bad.20Rust.20SIMD.20perf.3F.html#242148703">(Jun 10 2021 at 00:51)</a>:</h4>
<p><span class="user-mention silent" data-user-id="281757">Jubilee</span> <a href="#narrow/stream/257879-project-portable-simd/topic/Examples.20of.20bad.20Rust.20SIMD.20perf.3F/near/242118766">said</a>:</p>
<blockquote>
<p>So one thing we could use to help motivate a solution to <a href="https://github.com/rust-lang/rust/issues/64609">https://github.com/rust-lang/rust/issues/64609</a> is if we could find examples of bad or divergent SIMD performance for Rust on a given architecture vs C (clang) on a given architecture. I had a conversation or two with people who have somewhat more familiarity with the compiler-level SIMD stuff (but not necessarily more familiarity with SIMD overall) and they expect LLVM to see through and properly handle the "pass through memory" trick if things are inlined.</p>
<p>This obviously is not at all the case where we just completely scalarize things, so we're ignoring <a href="https://github.com/rust-lang/stdsimd/issues/76">stdsimd#76</a> for the purposes of this example.<br>
If we can cough up examples we can compare against, it would help us bench, profile, and test possible solutions.<br>
I'm also not actually limiting this to <strong>just</strong> C, clang just happens to be there and is also LLVM driven. Anything where our SIMD takes a beating vs. ${LANG} is a good example.</p>
</blockquote>
<p>Oh man, a real opportunity to ship my <em>real</em> code!</p>



<a name="242148777"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Examples%20of%20bad%20Rust%20SIMD%20perf%3F/near/242148777" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Examples.20of.20bad.20Rust.20SIMD.20perf.3F.html#242148777">(Jun 10 2021 at 00:53)</a>:</h4>
<p>JK, but I was planning on something similar to <a href="https://parallel-rust-cpp.github.io/v3.html">this</a> Rust high performance walkthrough:<br>
Work through a code in several stages by applying a single idea in each one, and show the corresponding perf/assembly against benchmarks/tooling to see if you're getting the expected results.</p>



<a name="242148803"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Examples%20of%20bad%20Rust%20SIMD%20perf%3F/near/242148803" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Examples.20of.20bad.20Rust.20SIMD.20perf.3F.html#242148803">(Jun 10 2021 at 00:53)</a>:</h4>
<p>But yes, if I get horribly performing SIMD code I'll gladly put it up to the exhibit museum</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>